const groupName = [{
		required: true,
		message: '单位名称不能为空',
		trigger: 'blur'
	},
	{
		min: 3,
		max: 16,
		message: '单位名称长度在 3 到 16 个字符之间',
		trigger: 'blur'
	},
]

const socialCode = [{
		required: true,
		message: '社会信用码不能为空',
		trigger: 'blur'
	},
	{
		min: 3,
		max: 33,
		message: '社会信用码长度在 3 到 33 个字符之间',
		trigger: 'blur'
	},
]

const legalPeo = [{
		required: true,
		message: '法人不能为空',
		trigger: 'blur'
	},
	{
		min: 2,
		max: 6,
		message: '名称长度在 2 到 6 个字符之间',
		trigger: 'blur'
	},
]

const legalPeoPhone = (rule, value, callback) => {
	if (!value) {
		return callback(new Error('法人电话不能为空'));
	} else {
		const reg =
			/^(0?(13[0-9]|15[012356789]|17[013678]|18[0-9]|14[57])[0-9]{8})|(400|800)([0-9\\-]{7,10})|(([0-9]{4}|[0-9]{3})(-| )?)?([0-9]{7,8})((-| |转)*([0-9]{1,4}))?$/
		if (reg.test(value)) {
			callback();
		} else {
			return callback(new Error('请输入正确的法人号码'));
		}
	}
};

const principalPeo = [{
		required: true,
		message: '主要负责人不能为空',
		trigger: 'blur'
	},
	{
		min: 2,
		max: 6,
		message: '名称长度在 2 到 6 个字符之间',
		trigger: 'blur'
	},
]

const principalPeoPhone = (rule, value, callback) => {
	if (!value) {
		return callback(new Error('主要负责人电话不能为空'));
	} else {
		const reg =
			/^(0?(13[0-9]|15[012356789]|17[013678]|18[0-9]|14[57])[0-9]{8})|(400|800)([0-9\\-]{7,10})|(([0-9]{4}|[0-9]{3})(-| )?)?([0-9]{7,8})((-| |转)*([0-9]{1,4}))?$/
		if (reg.test(value)) {
			callback();
		} else {
			return callback(new Error('请输入正确的主要负责人号码'));
		}
	}
};

const account = [{
		required: true,
		message: '系统对接账户不能为空',
		trigger: 'blur'
	},
	{
		min: 3,
		max: 20,
		message: '系统对接账号在 3 到 20 个字符之间',
		trigger: 'blur'
	},
]

const token = [{
		required: true,
		message: '系统对接令牌不能为空',
		trigger: 'blur'
	},
	{
		min: 3,
		max: 20,
		message: '系统对接令牌在 3 到 20 个字符之间',
		trigger: 'blur'
	},
]
const groupPhone = (rule, value, callback) => {
	if (!value) {
		return callback(new Error('单位电话不能为空'));
	} else {
		const reg =
			/^(0?(13[0-9]|15[012356789]|17[013678]|18[0-9]|14[57])[0-9]{8})|(400|800)([0-9\\-]{7,10})|(([0-9]{4}|[0-9]{3})(-| )?)?([0-9]{7,8})((-| |转)*([0-9]{1,4}))?$/
		if (reg.test(value)) {
			callback();
		} else {
			return callback(new Error('请输入正确的单位号码'));
		}
	}
};

const signProvince = [{
	required: true,
	message: '注册省份不能为空',
	trigger: 'blur'
}, ]

const signCity = [{
	required: true,
	message: '注册城市不能为空',
	trigger: 'blur'
}, ]

const signArea = [{
	required: true,
	message: '注册区/县不能为空',
	trigger: 'blur'
}, ]

const signStreet = [{
	required: true,
	message: '注册街道不能为空',
	trigger: 'blur'
}, ]

const detailAdress = [{
		required: true,
		message: '详细地址不能为空',
		trigger: 'blur'
	},
	{
		min: 3,
		max: 33,
		message: '详细地址长度在 3 到 33 个字符之间',
		trigger: 'blur'
	},
]

const networkAddress = [{
		required: true,
		message: '维保网点地址不能为空',
		trigger: 'blur'
	},
	{
		min: 3,
		max: 33,
		message: '维保网点地址长度在 3 到 33 个字符之间',
		trigger: 'blur'
	},
]

const allDayNum = (rule, value, callback) => {
	if (!value) {
		return callback(new Error('24小时电话不能为空'));
	} else {
		const reg =
			/^(0?(13[0-9]|15[012356789]|17[013678]|18[0-9]|14[57])[0-9]{8})|(400|800)([0-9\\-]{7,10})|(([0-9]{4}|[0-9]{3})(-| )?)?([0-9]{7,8})((-| |转)*([0-9]{1,4}))?$/
		if (reg.test(value)) {
			callback();
		} else {
			return callback(new Error('请输入正确的电话号码'));
		}
	}
};

const networkProvince = [{
	required: true,
	message: '注册网点省份不能为空',
	trigger: 'blur'
}, ]

const networkCity = [{
	required: true,
	message: '注册网点城市不能为空',
	trigger: 'blur'
}, ]

const networkArea = [{
	required: true,
	message: '注册网点区/县不能为空',
	trigger: 'blur'
}, ]

const networkStreet = [{
	required: true,
	message: '注册网点街道不能为空',
	trigger: 'blur'
}, ]

const networkprincipalPeo = [{
		required: true,
		message: '网点负责人不能为空',
		trigger: 'blur'
	},
	{
		min: 2,
		max: 6,
		message: '名称长度在 2 到 6 个字符之间',
		trigger: 'blur'
	},
]

const networkprincipalPeoPhone = (rule, value, callback) => {
	if (!value) {
		return callback(new Error('网点负责人电话不能为空'));
	} else {
		const reg =
			/^(0?(13[0-9]|15[012356789]|17[013678]|18[0-9]|14[57])[0-9]{8})|(400|800)([0-9\\-]{7,10})|(([0-9]{4}|[0-9]{3})(-| )?)?([0-9]{7,8})((-| |转)*([0-9]{1,4}))?$/
		if (reg.test(value)) {
			callback();
		} else {
			return callback(new Error('请输入正确的网点负责人电话'));
		}
	}
};

export {
	groupName,
	socialCode,
	legalPeo,
	legalPeoPhone,
	principalPeo,
	principalPeoPhone,
	account,
	token,
	groupPhone,
	signProvince,
	signCity,
	signArea,
	signStreet,
	detailAdress,
	networkAddress,
	allDayNum,
	networkProvince,
	networkCity,
	networkArea,
	networkStreet,
	networkprincipalPeo,
	networkprincipalPeoPhone,
}
